<?php
/**
 * DolphinGTK - phpGtk framework
 *
 * @package    DolphinGTK
 * @author     Askarov Ruslan
 * @copyright  Askarov Ruslan (c) 2010.
 * @link       http://groups.google.com/group/dolphingtk
 * @license    http://www.opensource.org/licenses/gpl-license.php GPL
 * @version    0.1
 * @since      PHP v.: 5.2.1
 * @subpackage desktop
 * @category   library
 * @filesource
 */

final class Tabber
{
  private $notebook;



  public function __construct()
  {
    if( class_exists('GtkNotebook') ) {
      $this->notebook = new GtkNotebook();
    } else {
      print "GtkNotebook - class not exists!\n";
    }
  }




  public function position( $pos )
  {
    if( $this->notebook ) {
      switch( $pos )
      {
        case 'left':
          $this->notebook->set_tab_pos(Gtk::POS_LEFT);
          break;
        case 'right':
          $this->notebook->set_tab_pos(Gtk::POS_RIGHT);
          break;
        case 'bottom':
          $this->notebook->set_tab_pos(Gtk::POS_BOTTOM);
          break;
        default:
          $this->notebook->set_tab_pos(Gtk::POS_TOP);
          break;
      }
    }
  }




  public function size( $width, $height )
  {
    if( is_numeric($width) && is_numeric($height) )
    {
      if( $this->notebook ) {
        $this->notebook->set_size_request(
          $width, $height
        );
      }
    }
  }




  public function add( $cont, $name ) {
    if( $this->notebook ) {
      $this->notebook->append_page($cont, new GtkLabel($name));
    }
  }




  public function get() {
    if( $this->notebook ) {
      return $this->notebook;
    }
  }




  public function next()
  {
    if( $this->notebook ) {
      $this->notebook->next_page();
    }
  }




  public function previous()
  {
    if( $this->notebook ) {
      $this->notebook->prev_page();
    }
  }



  public function set_page($page)
  {
    if( is_numeric($page) && $this->notebook ) {
    $this->notebook->set_current_page($page);
    }
  }



  public function get_page()
  {
    if( $this->notebook ) {
      $this->notebook->get_current_page();
    }
  }



  public function remove($page)
  {
    if( is_numeric($page) && $this->notebook ) {
    $this->notebook->remove_page($page);
    }
  }




  public function insert($child, $title = null, $position = 3 )
  {
    $title = new GtkLabel($title);
    if( $child instanceof GtkWidget && $this->notebook ) {
      $this->notebook->insert_page($child, $title, $position);
    }
  }




  public function scrollable($flag)
  {
    if( is_bool($flag) && $this->notebook ) {
      $this->notebook->set_scrollable($flag);
    }
  }

/*
 * Signal:
    * GtkNotebook: change-current-page
    * GtkNotebook: focus-tab
    * GtkNotebook: move-focus-out
    * GtkNotebook: select-page
    * GtkNotebook: switch-page
*/
}
?>